<template>
	<view class="coash-container">
		<u-navbar bgColor="#000000" autoBack height="90" placeholder fixed>
			<view class="u-nav-slot" slot="center">
				<!-- 正文内容 -->
				<text style="font-size: 46rpx;font-weight: bold;">教练</text>
			</view>
		</u-navbar>
		<view class="coash-info">
			<view class="info-left">
				<image src="../../static/imgs/coash1.png" mode=""></image>
			</view>
			<view class="info-right">
				<view class="info-item">
					<view class="top">{{carshInfo.fans}}</view>
					<view>粉丝</view>
				</view>
				<view class="info-item">
					<view class="top">{{carshInfo.follow}}</view>
					<view>动态</view>
				</view>
				<view class="info-item">
					<view class="top">{{carshInfo.follow}}</view>
					<view>关注</view>
				</view>
			</view>
		</view>
		<view class="coash-desc">
			<view class="desc-left">
				<view class="coash-name">{{user.nickname}}</view>
				<view class="coash-intor">
					{{user.introduction}}
				</view>
			</view>
			<view class="desc-right">
				高级.身材.肌肉.运动
			</view>
		</view>
		<view class="coash-course">
			<view class="course-title">
				<image src="../../static/imgs/course-icon.png" mode=""></image>
				<text>课程列表</text>
			</view>
			<view class="course-address">
				<text style="color: #6C6C6C;">课程地点:</text>
				<text>广州市珠海区289号</text>
			</view>
			<view class="course-content">
				<view class="course-item" v-for="item in courseList" :key="item.id">
					<image src="../../static/imgs/coash2.png" mode=""></image>
					<view class="course-num">5节课程</view>
					<view class="course-title">
						{{item.name}}
					</view>
				</view>
			</view>
			<view class="coash-btn" @click="test">
				{{ userFollow?'已关注':'关注'}}
			</view>

		</view>
	</view>
</template>

<script>
	import {
		carshInfo,
	} from '../../api/index.js'
	import {
		followCoarsh
	} from "../../api/course.js"
	import {
		TOAST
	} from "@/utils/utils.js"
	export default {
		data() {
			return {
				userId: "",
				carshInfo: {},
				courseList: [],
				user: {},
				// 关注
				userFollow:""
			};
		},
		onLoad(option) {
			this.userId = option.id
		},
		onShow() {
			this.getCarshInfo()
		},
		methods: {
			// 获取教练详情信息
			getCarshInfo() {
				carshInfo(this.userId).then(res => {
					this.carshInfo = res.data
					this.courseList = res.data.courseList
					this.user = res.data.user
					this.userFollow=res.data.userFollow
				})
			},
			test() {
				followCoarsh(this.userId).then(res => {
					if (res.code === 200) {
						TOAST("关注成功")
						this.getCarshInfo()
					}
				})
			}
		},

	}
</script>

<style lang="scss" scoped>
	.coash-container {
		height: 100%;
		background-color: #000000;
		padding: 0 60rpx;
		overflow-y: auto;

		.coash-info {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.info-left {
				image {
					width: 420rpx;
					height: 380rpx;
				}
			}

			.info-right {
				height: 380rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.info-item {
					text-align: center;

					.top {
						text-align: center;
						font-size: 60rpx;
						color: #7A0056;
						font-weight: bold;
						margin-bottom: 20rpx;
					}
				}

			}
		}

		.coash-desc {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin: 40rpx 0;

			.desc-left {
				.coash-name {
					font-size: 60rpx;
					font-weight: bold;
					margin-bottom: 20rpx;
				}

				.coash-intor {
					color: #6C6C6C;
				}
			}

			.desc-right {
				padding: 0 30rpx;
				border-radius: 10rpx;
				background: #262626;
				line-height: 80rpx;
				height: 80rpx;
			}
		}

		.coash-course {
			.course-title {
				display: flex;
				align-items: center;
				margin: 40rpx 0;

				image {
					width: 63rpx;
					height: 63rpx;
					margin-right: 20rpx;
				}

				text {

					font-weight: bold;
					font-size: 28rpx;
				}
			}

			.course-address {}

			.course-content {
				display: flex;
				align-items: center;
				justify-content: space-between;
				flex-wrap: wrap;
				margin: 40rpx 0;

				.course-item {
					width: 205rpx;
					position: relative;

					image {
						width: 205rpx;
						height: 205rpx;
					}

					.course-num {
						position: absolute;
						bottom: 130rpx;
						right: 20rpx;
						width: 100rpx;
						border-radius: 10rpx;
						opacity: 0.52;
						background: #262626;
						height: 50rpx;
						line-height: 50rpx;
						text-align: center;
						font-size: 14rpx;
					}
				}
			}

			.coash-btn {

				border-radius: 50rpx;
				background: #F4EA2A;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #000000;
				font-size: 30rpx;
				font-weight: bold;
				margin: 60rpx 0;
			}

		}


	}
</style>
